package com.example.demo.web.controller;


import com.example.demo.bean.BasePrivilege;
import com.example.demo.service.IBasePriviligeService;
import com.example.demo.utils.Message;
import com.example.demo.utils.MessageUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController("/basePrivilige")
@RequestMapping("/basePrivilige")
@Validated
public class BasePriviligeController {
    @Autowired
    private IBasePriviligeService basePriviligeService;

    @GetMapping("query")
    public Message query(String name){
        List<BasePrivilege>list=basePriviligeService.query(name);
        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BasePrivilege basePrivilege){
        basePriviligeService.saveOrUpdate(basePrivilege);
        return MessageUtil.success("操作成功");
    }
    @DeleteMapping("deleteById")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="id",value = "模块编号",required = true,paramType = "query"),
    })
    public Message deleteById(@NotNull Long id){
        basePriviligeService.deleteById(id);
        return MessageUtil.success("操作成功");
    }



}
